home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / Libraries / BSP Tree 1.2 / BSP Tree FAQ < prev   
Encoding:
Text File  |  1995-11-27  |  60.5 KB  |  1,452 lines  |  [TEXT/CWIE]

  1.  
  2.                    BSP TREE FREQUENTLY ASKED QUESTIONS (FAQ)
  3.                                        
  4.    
  5.      _________________________________________________________________
  6.    
  7. Questions
  8.  
  9.    
  10.     1. About this document
  11.     2. Acknowledgements
  12.     3. How can you contribute?
  13.     4. About the pseudo C++ code
  14.     5. What is a BSP Tree?
  15.     6. How do you build a BSP Tree?
  16.     7. How do you partition a polygon with a plane?
  17.     8. How do you remove hidden surfaces with a BSP Tree?
  18.     9. How do you compute analytic visibility with a BSP Tree?
  19.    10. How do you accelerate ray tracing with a BSP Tree?
  20.    11. How do you perform boolean operations on polytopes with a BSP
  21.        Tree?
  22.    12. How do you perform collision detection with a BSP Tree?
  23.    13. How do you handle dynamic scenes with a BSP Tree?
  24.    14. How do you compute shadows with a BSP Tree?
  25.    15. How do you extract connectivity information from BSP Trees?
  26.    16. How are BSP Trees useful for robot motion planning?
  27.    17. How are BSP Trees used in DOOM?
  28.    18. How can you make a BSP Tree more robust?
  29.    19. How efficient is a BSP Tree?
  30.    20. How can you make a BSP Tree more efficient?
  31.    21. How can you avoid recursion?
  32.    22. What is the history of BSP Trees?
  33.    23. Where can you find sample code and related online resources?
  34.    24. References
  35.        
  36.    
  37.      _________________________________________________________________
  38.    
  39. Answers
  40.  
  41.     _
  42.    About this document_
  43.        
  44.        _General_
  45.        The purpose of this document is to provide answers to Frequently
  46.        Asked Questions about Binary Space Partitioning (BSP) Trees. This
  47.        document will be posted monthly to comp.graphics.algorithms. It is
  48.        also available via WWW at the URL:
  49.        
  50.         http://www.qualia.com/bspfaq/
  51.    
  52.        
  53.        The most recent newsgroup posting of this document is available
  54.        via ftp at the following URLs:
  55.        
  56.         file://www.qualia.com/pub/bspfaq/bspfaq.txt
  57.             ftp://rtfm.mit.edu/pub/usenet/news.answers/graphics/bsptree-
  58.             faq
  59.    
  60.        
  61.        _Requesting the FAQ by mail_
  62.        You can request that the FAQ be mailed to you in plain text and
  63.        HTML formats by sending e-mail to bspfaq@qualia.com with a subject
  64.        line of "SEND BSP TREE [what]". The "[what]" should be replaced
  65.        with any combination of "TEXT" and "HTML". Respectively, these
  66.        will return to you a plain text version of the FAQ, and an HTML
  67.        formatted version of the FAQ viewable with Mosaic or Netscape.
  68.        
  69.        _Copyrights and distribution_
  70.        This document is maintained by Bretton Wade, lead developer for
  71.        Qualia, Incorporated, and a graduate of the Cornell University
  72.        Program of Computer Graphics.
  73.        
  74.        This document, and all its associated parts, are Copyright ©
  75.        1995, Bretton Wade. All rights reserved. Permisson to distribute
  76.        this collection, in part or full, via electronic means (emailed,
  77.        posted or archived) or printed copy are granted providing that no
  78.        charges are involved, reasonable attempt is made to use the most
  79.        current version, and all credits and copyright notices are
  80.        retained. If you make a link to the WWW page, please inform the
  81.        maintainer so he can construct reciprocal links.
  82.        
  83.        Requests for other distribution rights, including incorporation in
  84.        commercial products, such as books, magazine articles, CD-ROMs,
  85.        and binary applications should be made to bspfaq@qualia.com.
  86.        
  87.        _Warranty and disclaimer_
  88.        This article is provided as is without any express or implied
  89.        warranties. While every effort has been taken to ensure the
  90.        accuracy of the information contained in this article, the
  91.        author/maintainer/contributors assume(s) no responsibility for
  92.        errors or omissions, or for damages resulting from the use of the
  93.        information contained herein.
  94.        
  95.        The contents of this article do not necessarily represent the
  96.        opinions of Qualia, Incorporated.
  97.        --
  98.        _Last Update: 11/27/95 16:26:21_
  99.        
  100.        _
  101.    Acknowledgements_
  102.        
  103.        _About the contributors_
  104.        This document would not have been possible without the selfless
  105.        contributions and efforts of many individuals. I would like to
  106.        take the opportunity to thank each one of them. Please be aware
  107.        that these people may not be amenable to recieving e-mail on a
  108.        random basis. If you have any special questions, please contact
  109.        Bretton Wade (bwade@qualia.com or bspfaq@qualia.com) before
  110.        trying to contact anyone else on this list.
  111.        
  112.        _Contributors_
  113.           + Bruce Naylor (naylor@research.att.com)
  114.           + Richard Lobb (richard@cs.auckland.ac.nz)
  115.           + Dani Lischinski (danix@cs.washington.edu)
  116.           + Chris Schoeneman (crs@lightscape.com)
  117.           + Philip Hubbard (pmh@graphics.cornell.edu)
  118.           + Jim Arvo (arvo@graphics.cornell.edu)
  119.           + Kevin Ryan (kryan@access.digex.net)
  120.           + Joseph Fiore (fiore@cs.buffalo.edu)
  121.           + Lukas Rosenthaler (rosenth@foto.chemie.unibas.ch)
  122.           + Anson Tsao (ansont@hookup.net)
  123.           + Robert Zawarski (zawarski@chaph.usc.edu)
  124.           + Ron Capelli (capelli@vnet.ibm.com)
  125.           + Eric A. Haines (erich@eye.com)
  126.           + Ian CR Mapleson (mapleson@cee.hw.ac.uk)
  127.           + Richard Dorman (richard@cs.wits.ac.za)
  128.           + Steve Larsen (larsen@sunset.cs.utah.edu)
  129.           + Timothy Miller (tsm@cs.brown.edu)
  130.           + Ben Trumbore (wbt@graphics.cornell.edu)
  131.           + Richard Matthias (richardm@cogs.susx.ac.uk)
  132.           + Ken Shoemake (shoemake@graphics.cis.upenn.edu)
  133.           + Seth Teller (seth@theory.lcs.mit.edu)
  134.           + Peter Shirley (shirley@graphics.cornell.edu)
  135.           + Michael Abrash (mikeab@idece2.idsoftware.com)
  136.           + Robert Schmidt (robert@idt.unit.no)
  137.           + Samuel P. Uselton (uselton@nas.nasa.gov)
  138.    
  139.        
  140.        If I have neglected to mention your name, and you contributed,
  141.        please let me know immediately!
  142.        --
  143.        _Last Update: 11/27/95 16:26:21_
  144.        
  145.        _
  146.    How can you contribute?_
  147.        
  148.        Please send all new questions, corrections, suggestions, and
  149.        contributions to bsp-faq@graphics.cornell.edu.
  150.        --
  151.        _Last Update: 11/27/95 16:26:21_
  152.        
  153.        _
  154.    About the pseudo C++ code_
  155.        
  156.        _Overview_
  157.        The general efficiency of C++ makes it a well suited language for
  158.        programming computer graphics. Furthermore, the abstract nature of
  159.        the language allows it to be used effectively as a psuedo code for
  160.        demonstrative purposes. I will use C++ notation for all the
  161.        examples in this document.
  162.        
  163.        In order to provide effective examples, it is necessary to assume
  164.        that certain classes already exist, and can be used without
  165.        presenting excessive details of their operation. Basic classes
  166.        such as lists and arrays fall into this category.
  167.        
  168.        Other classes which will be very useful for examples need to be
  169.        presented here, but the definitions will be generic to allow for
  170.        freedom of interpretation. I assume points and vectors to each be
  171.        an array of 3 real numbers (X, Y, Z).
  172.        
  173.        Planes are represented as an array of 4 real numbers (A, B, C, D).
  174.        The vector (A, B, C) is the normal vector to the plane. Polygons
  175.        are structures composited from an array of points, which are the
  176.        vertices, and a plane.
  177.        
  178.        The overloaded operator for a dot product (inner product, scalar
  179.        product, etc.) of two vectors is the '|' symbol. This has two
  180.        advantages, the first of which is that it can't be confused with
  181.        the scalar multiplication operator. The second is that precedence
  182.        of C++ operators will usually require that dot product operations
  183.        be parenthesized, which is consistent with the linear algebra
  184.        notation for an inner product.
  185.        
  186.        The code for BSP trees presented here is intended to be
  187.        educational, and may or may not be very efficient. For the sake of
  188.        clarity, the BSP tree itself will not be defined as a class.
  189.        --
  190.        _Last Update: 11/27/95 16:26:21_
  191.        
  192.        _
  193.    What is a BSP Tree?_
  194.        
  195.        _Overview_ A Binary Space Partitioning (BSP) tree represents a
  196.        recursive, hierarchical partitioning, or subdivision, of
  197.        n-dimensional space into convex subspaces. BSP tree construction
  198.        is a process which takes a subspace and partitions it by any
  199.        hyperplane that intersects the interior of that subspace. The
  200.        result is two new subspaces that can be further partitioned by
  201.        recursive application of the method.
  202.        
  203.        A "hyperplane" in n-dimensional space is an n-1 dimensional object
  204.        which can be used to divide the space into two half-spaces. For
  205.        example, in three dimensional space, the "hyperplane" is a plane.
  206.        In two dimensional space, a line is used.
  207.        
  208.        BSP trees are extremely versatile, because they are powerful
  209.        sorting and classification structures. They have uses ranging from
  210.        hidden surface removal and ray tracing hierarchies to solid
  211.        modeling and robot motion planning.
  212.        
  213.        _Example_
  214.        An easy way to think about BSP trees is to limit the discussion to
  215.        two dimensions. To simplify the situation, let's say that we will
  216.        use only lines parallel to the X or Y axis, and that we will
  217.        divide the space equally at each node. For example, given a square
  218.        somewhere in the XY plane, we select the first split, and thus the
  219.        root of the BSP Tree, to cut the square in half in the X
  220.        direction. At each slice, we will choose a line of the opposite
  221.        orientation from the last one, so the second slice will divide
  222.        each of the new pieces in the Y direction. This process will
  223.        continue recursively until we reach a stopping point, and looks
  224.        like this:
  225.        
  226. +-----------+      +-----+-----+      +-----+-----+
  227. |           |      |     |     |      |     |     |
  228. |           |      |     |     |      |  d  |     |
  229. |           |      |     |     |      |     |     |
  230. |     a     |  ->  |  b  X  c  |  ->  +--Y--+  f  |  -> ...
  231. |           |      |     |     |      |     |     |
  232. |           |      |     |     |      |  e  |     |
  233. |           |      |     |     |      |     |     |
  234. +-----------+      +-----+-----+      +-----+-----+
  235.    
  236.        
  237.        The resulting BSP tree looks like this at each step:
  238.       _a_                  _X_                  _X_           ...
  239.             _ _          -/ \+     _ _        -/ \+
  240.             _ _          /   \     _ _        /   \
  241.                       _b_     _c_            _Y_     _f_
  242.             _  _                         -/ \+
  243.             _  _                         /   \
  244.                                       _e_     _d_
  245.    
  246.        
  247.        _Other space partitioning structures_
  248.        BSP trees are closely related to Quadtrees and Octrees. Quadtrees
  249.        and Octrees are space partitioning trees which recursively divide
  250.        subspaces into four and eight new subspaces, respectively. A BSP
  251.        Tree can be used to simulate both of these structures.
  252.        --
  253.        _Last Update: 11/27/95 16:26:21_
  254.        
  255.        _
  256.    How do you build a BSP Tree?_
  257.        
  258.        _Overview_
  259.        Given a set of polygons in three dimensional space, we want to
  260.        build a BSP tree which contains all of the polygons. For now, we
  261.        will ignore the question of how the resulting tree is going to be
  262.        used.
  263.        
  264.        The algorithm to build a BSP tree is very simple:
  265.        
  266.          1. Select a partition plane.
  267.          2. Partition the set of polygons with the plane.
  268.          3. Recurse with each of the two new sets.
  269.    
  270.        
  271.        _Choosing the partition plane_
  272.        The choice of partition plane depends on how the tree will be
  273.        used, and what sort of efficiency criteria you have for the
  274.        construction. For some purposes, it is appropriate to choose the
  275.        partition plane from the input set of polygons. Other applications
  276.        may benefit more from axis aligned orthogonal partitions.
  277.        
  278.        In any case, you want to evaluate how your choice will affect the
  279.        results. It is desirable to have a balanced tree, where each leaf
  280.        contains roughly the same number of polygons. However, there is
  281.        some cost in achieving this. If a polygon happens to span the
  282.        partition plane, it will be split into two or more pieces. A poor
  283.        choice of the partition plane can result in many such splits, and
  284.        a marked increase in the number of polygons. Usually there will be
  285.        some trade off between a well balanced tree and a large number of
  286.        splits.
  287.        
  288.        _Partitioning polygons_
  289.        Partitioning a set of polygons with a plane is done by classifying
  290.        each member of the set with respect to the plane. If a polygon
  291.        lies entirely to one side or the other of the plane, then it is
  292.        not modified, and is added to the partition set for the side that
  293.        it is on. If a polygon spans the plane, it is split into two or
  294.        more pieces and the resulting parts are added to the sets
  295.        associated with either side as appropriate.
  296.        
  297.        _When to stop_
  298.        The decision to terminate tree construction is, again, a matter of
  299.        the specific application. Some methods terminate when the number
  300.        of polygons in a leaf node is below a maximum value. Other methods
  301.        continue until every polygon is placed in an internal node.
  302.        Another criteria is a maximum tree depth.
  303.        
  304.        _Pseudo C++ code example_
  305.        Here is an example of how you might code a BSP tree:
  306.        
  307. struct  BSP_tree
  308. {
  309.    plane     partition;
  310.    list      polygons;
  311.    BSP_tree  *front,
  312.              *back;
  313. };
  314.    This structure definition will be used for all subsequent example
  315.        code. It stores pointers to its children, the partitioning plane
  316.        for the node, and a list of polygons coincident with the partition
  317.        plane. For this example, there will always be at least one polygon
  318.        in the coincident list: the polygon used to determine the
  319.        partition plane. A constructor method for this structure should
  320.        initialize the child pointers to NULL.
  321.        
  322. void    Build_BSP_Tree (BSP_tree *tree, list polygons)
  323. {
  324.    polygon   *root = polygons.Get_From_List ();
  325.    tree->partition = root->Get_Plane ();
  326.    tree->polygons.Add_To_List (root);
  327.    list      front_list,
  328.              back_list;
  329.    polygon   *poly;
  330.    while ((poly = polygons.Get_From_List ()) != 0)
  331.    {
  332.       int   result = tree->partition.Classify_Polygon (poly);
  333.       switch (result)
  334.       {
  335.          case COINCIDENT:
  336.             tree->polygons.Add_To_List (poly);
  337.             break;
  338.          case IN_BACK_OF:
  339.             backlist.Add_To_List (poly);
  340.             break;
  341.          case IN_FRONT_OF:
  342.             frontlist.Add_To_List (poly);
  343.             break;
  344.          case SPANNING:
  345.             polygon   *front_piece, *back_piece;
  346.             Split_Polygon (poly, tree->partition, front_piece, back_piece);
  347.             backlist.Add_To_List (back_piece);
  348.             frontlist.Add_To_List (front_piece);
  349.             break;
  350.       }
  351.    }
  352.    if ( ! front_list.Is_Empty_List ())
  353.    {
  354.       tree->front = new BSP_tree;
  355.       Build_BSP_Tree (tree->front, front_list);
  356.    }
  357.    if ( ! back_list.Is_Empty_List ())
  358.    {
  359.       tree->back = new BSP_tree;
  360.       Build_BSP_Tree (tree->back, back_list);
  361.    }
  362. }
  363.    This routine recursively constructs a BSP tree using the above
  364.        definition. It takes the first polygon from the input list and
  365.        uses it to partition the remainder of the set. The routine then
  366.        calls itself recursively with each of the two partitions. This
  367.        implementation assumes that all of the input polygons are convex.
  368.        
  369.        One obvious improvement to this example is to choose the
  370.        partitioning plane more intelligently. This issue is addressed
  371.        separately in the section, "How can you make a BSP Tree more
  372.        efficient?".
  373.        --
  374.        _Last Update: 11/27/95 16:26:21_
  375.        
  376.        _
  377.    How do you partition a polygon with a plane?_
  378.        
  379.        _Overview_
  380.        Partitioning a polygon with a plane is a matter of determining
  381.        which side of the plane the polygon is on. This is referred to as
  382.        a front/back test, and is performed by testing each point in the
  383.        polygon against the plane. If all of the points lie to one side of
  384.        the plane, then the entire polygon is on that side and does not
  385.        need to be split. If some points lie on both sides of the plane,
  386.        then the polygon is split into two or more pieces.
  387.        
  388.        The basic algorithm is to loop across all the edges of the polygon
  389.        and find those for which one vertex is on each side of the
  390.        partition plane. The intersection points of these edges and the
  391.        plane are computed, and those points are used as new vertices for
  392.        the resulting pieces.
  393.        
  394.        _Implementation notes_
  395.        Classifying a point with respect to a plane is done by passing the
  396.        (x, y, z) values of the point into the plane equation, Ax + By +
  397.        Cz + D = 0. The result of this operation is the distance from the
  398.        plane to the point along the plane's normal vector. It will be
  399.        positive if the point is on the side of the plane pointed to by
  400.        the normal vector, negative otherwise. If the result is 0, the
  401.        point is on the plane.
  402.        
  403.        For those not familiar with the plane equation, The values A, B,
  404.        and C are the coordinate values of the normal vector. D can be
  405.        calculated by substituting a point known to be on the plane for x,
  406.        y, and z.
  407.        
  408.        Convex polygons are generally easier to deal with in BSP tree
  409.        construction than concave ones, because splitting them with a
  410.        plane always results in exactly two convex pieces. Furthermore,
  411.        the algorithm for splitting convex polygons is straightforward and
  412.        robust. Splitting of concave polygons, especially self
  413.        intersecting ones, is a significant problem in its own right.
  414.        
  415.        _Pseudo C++ code example_
  416.        Here is a very basic function to split a convex polygon with a
  417.        plane:
  418.        
  419. void Split_Polygon (polygon *poly, plane *part, polygon *&front, polygon *&back
  420. )
  421. {
  422.    int   count = poly->NumVertices (),
  423.          out_c = 0, in_c = 0;
  424.    point ptA, ptB,
  425.          outpts[MAXPTS],
  426.          inpts[MAXPTS];
  427.    real sideA, sideB;
  428.    ptA = poly->Vertex (count - 1);
  429.    sideA = part->Classify_Point (ptA);
  430.    for (short i = -1; ++i < count;)
  431.    {
  432.       ptB = poly->Vertex (i);
  433.       sideB = part->Classify_Point (ptB);
  434.       if (sideB > 0)
  435.       {
  436.          if (sideA < 0)
  437.          {
  438.             // compute the intersection point of the line
  439.             // from point A to point B with the partition
  440.             // plane. This is a simple ray-plane intersection.
  441.             vector v = ptB - ptA;
  442.             real   sect = - part->Classify_Point (ptA) / (part->Normal () | v);
  443.             outpts[out_c++] = inpts[in_c++] = ptA + (v * sect);
  444.          }
  445.          outpts[out_c++] = ptB;
  446.       }
  447.       else if (sideB < 0)
  448.       {
  449.          if (sideA > 0)
  450.          {
  451.             // compute the intersection point of the line
  452.             // from point A to point B with the partition
  453.             // plane. This is a simple ray-plane intersection.
  454.             vector v = ptB - ptA;
  455.             real   sect = - part->Classify_Point (ptA) / (part->Normal () | v);
  456.             outpts[out_c++] = inpts[in_c++] = ptA + (v * sect);
  457.          }
  458.          inpts[in_c++] = ptB;
  459.       }
  460.       else
  461.          outpts[out_c++] = inpts[in_c++] = ptB;
  462.       ptA = ptB;
  463.       sideA = sideB;
  464.    }
  465.    front = new polygon (outpts, out_c);
  466.    back = new polygon (inpts, in_c);
  467. }
  468.    A simple extension to this code that is good for BSP trees is to
  469.        combine its functionality with the routine to classify a polygon
  470.        with respect to a plane.
  471.        
  472.        Note that this code is not robust, since numerical stability may
  473.        cause errors in the classification of a point. The standard
  474.        solution is to make the plane "thick" by use of an _epsilon_
  475.        value.
  476.        --
  477.        _Last Update: 11/27/95 16:26:21_
  478.        
  479.        _
  480.    How do you remove hidden surfaces with a BSP Tree?_
  481.        
  482.        _Overview_
  483.        Probably the most common application of BSP trees is hidden
  484.        surface removal in three dimensions. BSP trees provide an elegant,
  485.        efficient method for sorting polygons via a depth first tree walk.
  486.        This fact can be exploited in a back to front "painter's
  487.        algorithm" approach to the visible surface problem, or a front to
  488.        back scanline approach.
  489.        
  490.        BSP trees are well suited to interactive display of static (not
  491.        moving) geometry because the tree can be constructed as a
  492.        preprocess. Then the display from any arbitrary viewpoint can be
  493.        done in linear time. Adding dynamic (moving) objects to the scene
  494.        is discussed in another section of this document.
  495.        
  496.        _Painter's algorithm_
  497.        The idea behind the painter's algorithm is to draw polygons far
  498.        away from the eye first, followed by drawing those that are close
  499.        to the eye. Hidden surfaces will be written over in the image as
  500.        the surfaces that obscure them are drawn. One condition for a
  501.        successful painter's algorithm is that there be a single plane
  502.        which separates any two objects. This means that it might be
  503.        necessary to split polygons in certain configurations. For
  504.        example, this case can not be drawn correctly with a painter's
  505.        algorithm:
  506.        
  507.                           +------+
  508.                           |      |
  509.           +---------------|      |--+
  510.           |               |      |  |
  511.           |               |      |  |
  512.           |               |      |  |
  513.           |      +--------|      |--+
  514.           |      |        |      |
  515.        +--|      |--------+      |
  516.        |  |      |               |
  517.        |  |      |               |
  518.        |  |      |               |
  519.        +--|      |---------------+
  520.           |      |
  521.           +------+
  522.    One reason that BSP trees are so elegant for the painter's algorithm
  523.        is that the splitting of difficult polygons is an automatic part
  524.        of tree construction. Note that only one of these two polygons
  525.        needs to be split in order to resolve the problem.
  526.        
  527.        To draw the contents of the tree, perform a back to front tree
  528.        traversal. Begin at the root node and classify the eye point with
  529.        respect to its partition plane. Draw the subtree at the far child
  530.        from the eye, then draw the polygons in this node, then draw the
  531.        near subtree. Repeat this procedure recursively for each subtree.
  532.        
  533.        _Scanline hidden surface removal_
  534.        It is just as easy to traverse the BSP tree in front to back order
  535.        as it is for back to front. We can use this to our advantage in a
  536.        scanline method method by using a write mask which will prevent
  537.        pixels from being written more than once. This will represent
  538.        significant speedups if a complex lighting model is evaluated for
  539.        each pixel, because the painter's algorithm will blindly evaluate
  540.        the same pixel many times.
  541.        
  542.        The trick to making a scanline approach successful is to have an
  543.        efficient method for masking pixels. One way to do this is to
  544.        maintain a list of pixel spans which have not yet been written to
  545.        for each scan line. For each polygon scan converted, only pixels
  546.        in the available spans are written, and the spans are updated
  547.        accordingly.
  548.        
  549.        The scan line spans can be represented as binary trees, which are
  550.        just one dimensional BSP trees. This technique can be expanded to
  551.        a two dimensional screen coverage algorithm using a two
  552.        dimensional BSP tree to represent the masked regions. Any convex
  553.        partitioning scheme, such as a quadtree, can be used with similar
  554.        effect.
  555.        
  556.        _Implementation notes_
  557.        When building a BSP tree specifically for hidden surface removal,
  558.        the partition planes are usually chosen from the input polygon
  559.        set. However, any arbitrary plane can be used if there are no
  560.        intersecting or concave polygons, as in the example above.
  561.        
  562.        _Pseudo C++ code example_
  563.        Using the BSP_tree structure defined in the section, "How do you
  564.        build a BSP Tree?", here is a simple example of a back to front
  565.        tree traversal:
  566.        
  567. void    Draw_BSP_Tree (BSP_tree *tree, point eye)
  568. {
  569.    real   result = tree->partition.Classify_Point (eye);
  570.    if (result > 0)
  571.    {
  572.       Draw_BSP_Tree (tree->back, eye);
  573.       tree->polygons.Draw_Polygon_List ();
  574.       Draw_BSP_Tree (tree->front, eye);
  575.    }
  576.    else if (result < 0)
  577.    {
  578.       Draw_BSP_Tree (tree->front, eye);
  579.       tree->polygons.Draw_Polygon_List ();
  580.       Draw_BSP_Tree (tree->back, eye);
  581.    }
  582.    else // result is 0
  583.    {
  584.       // the eye point is on the partition plane...
  585.       Draw_BSP_Tree (tree->front, eye);
  586.       Draw_BSP_Tree (tree->back, eye);
  587.    }
  588. }
  589.    If the eye point is classified as being on the partition plane, the
  590.        drawing order is unclear. This is not a problem if the
  591.        Draw_Polygon_List routine is smart enough to not draw polygons
  592.        that are not within the viewing frustum. The coincident polygon
  593.        list does not need to be drawn in this case, because those
  594.        polygons will not be visible to the user.
  595.        
  596.        It is possible to substantially improve the quality of this
  597.        example by including the viewing direction vector in the
  598.        computation. You can determine that entire subtrees are behind the
  599.        viewer by comparing the view vector to the partition plane normal
  600.        vector. This test can also make a better decision about tree
  601.        drawing when the eye point lies on the partition plane. It is
  602.        worth noting that this improvement resembles the method for
  603.        tracing a ray through a BSP tree, which is discussed in another
  604.        section of this document.
  605.        
  606.        Front to back tree traversal is accomplished in exactly the same
  607.        manner, except that the recursive calls to Draw_BSP_Tree occur in
  608.        reverse order.
  609.        --
  610.        _Last Update: 11/27/95 16:26:21_
  611.        
  612.        _
  613.    How do you compute analytic visibility with a BSP Tree?_
  614.        
  615.        _Overview_
  616.        
  617.        --
  618.        _Last Update: 11/27/95 16:26:21_
  619.        
  620.        _
  621.    How do you accelerate ray tracing with a BSP Tree?_
  622.        
  623.        _Overview_
  624.        Ray tracing a BSP tree is very similar to hidden surface removal
  625.        with a BSP tree. The algorithm is a simple forward tree walk, with
  626.        a few additions that apply to ray casting.
  627.        
  628.        MORE TO COME
  629.        
  630.        
  631.        --
  632.        _Last Update: 11/27/95 16:26:21_
  633.        
  634.        _
  635.    How do you perform boolean operations on polytopes with a BSP Tree?_
  636.        
  637.        _Overview_
  638.        There are two major classes of solid modeling methods with BSP
  639.        trees. For both methods, it is useful to introduce the notion of
  640.        an in/out test.
  641.        
  642.        An in/out test is a different way of talking about the front/back
  643.        test we have been using to classify points with respect to planes.
  644.        The necessity for this shift in thought is evident when
  645.        considering polytopes instead of just polygons. A point can not be
  646.        merely in front or back of a polytope, but inside or outside.
  647.        Somewhat formally, a point is inside of a polytope if it is inside
  648.        of, or in back of, each hyperplane which composes the polytope,
  649.        otherwise it is outside.
  650.        
  651.        _Incremental construction_
  652.        Incremental construction of a BSP Tree is the process of inserting
  653.        convex polytopes into the tree one by one. Each polytope has to be
  654.        processed according to the operation desired.
  655.        
  656.        It is useful to examine the construction process in two
  657.        dimensions. Consider the following figure:
  658.        
  659.  
  660. A               B
  661.  +-------------+
  662.  |             |
  663.  |             |
  664.  |      E      |        F
  665.  |       +-----+-------+
  666.  |       |     |       |
  667.  |       |     |       |
  668.  |       |     |       |
  669.  +-------+-----+       |
  670. D        |      C      |
  671.          |             |
  672.          |             |
  673.          +-------------+
  674.         H               G
  675.    Two polygons, ABCD, and EFGH, are to be inserted into the tree. We
  676.        wish to find the union of these two polygons. Start by inserting
  677.        polygon ABCD into the tree, choosing the splitting hyperplanes to
  678.        be coincident with the edges. The tree looks like this after
  679.        insertion of ABCD:
  680.        
  681.  
  682.                 _AB_
  683.               -/  \+
  684.               /    \
  685.              /      *
  686.             _BC_
  687.           -/  \+
  688.           /    \
  689.          /      *
  690.         _CD_
  691.       -/  \+
  692.       /    \
  693.      /      *
  694.     _DA_
  695.   -/  \+
  696.   /    \
  697.  *      *
  698.    Now, polygon EFGH is inserted into the tree, one polygon at a time.
  699.        The result looks like this:
  700.  
  701. A               B
  702.  +-------------+
  703.  |             |
  704.  |             |
  705.  |      E      |J       F
  706.  |       +-----+-------+
  707.  |       |     |       |
  708.  |       |     |       |
  709.  |       |     |       |
  710.  +-------+-----+       |
  711. D        |L    :C      |
  712.          |     :       |
  713.          |     :       |
  714.          +-----+-------+
  715.         H      K        G
  716.  
  717.                         AB
  718.                       -/  \+
  719.                       /    \
  720.                      /      *
  721.                     BC
  722.                   -/  \+
  723.                   /    \
  724.                  /      \
  725.                 CD       \
  726.               -/  \+      \
  727.               /    \       \
  728.              /      \       \
  729.             DA       \       \
  730.           -/  \+      \       \
  731.           /    \       \       \
  732.          /      *       \       \
  733.         EJ              KH       \
  734.       -/  \+          -/  \+      \
  735.       /    \          /    \       \
  736.      /      *        /      *       \
  737.     LE              HL              JF
  738.   -/  \+          -/  \+          -/  \+
  739.   /    \          /    \          /    \
  740.  *      *        *      *        FG     *
  741.                                -/  \+
  742.                                /    \
  743.                               /      *
  744.                              GK
  745.                            -/  \+
  746.                            /    \
  747.                           *      *
  748.    Notice that when we insert EFGH, we split edges EF and HE along the
  749.        edges of ABCD. this has the effect of dividing these segments into
  750.        pieces which are inside ABCD, and outside ABCD. Segments EJ and LE
  751.        will not be part of the boundary of the union. We could have saved
  752.        our selves some work by not inserting them into the tree at all.
  753.        For a union operation, you can always throw away segments that
  754.        land in inside nodes. You must be careful about this though. What
  755.        I mean is that any segments which land in inside nodes of side the
  756.        pre-existing tree, not the tree as it is being constructed. EJ and
  757.        LE landed in an inside node of the tree for polygon ABCD, and so
  758.        can be discarded.
  759.        
  760.        Our tree now looks like this:
  761. 
  762. A               B
  763.  +-------------+
  764.  |             |
  765.  |             |
  766.  |             |J       F
  767.  |             +-------+
  768.  |             |       |
  769.  |             |       |
  770.  |             |       |
  771.  +-------+-----+       |
  772. D        |L    :C      |
  773.          |     :       |
  774.          |     :       |
  775.          +-----+-------+
  776.         H      K        G
  777.  
  778.                         AB
  779.                       -/  \+
  780.                       /    \
  781.                      /      *
  782.                     BC
  783.                   -/  \+
  784.                   /    \
  785.                  /      \
  786.                 CD       \
  787.               -/  \+      \
  788.               /    \       \
  789.              /      \       \
  790.             DA       \       \
  791.           -/  \+      \       \
  792.           /    \       \       \
  793.          *      *       \       \
  794.                         KH       \
  795.                       -/  \+      \
  796.                       /    \       \
  797.                      /      *       \
  798.                     HL              JF
  799.                   -/  \+          -/  \+
  800.                   /    \          /    \
  801.                  *      *        FG     *
  802.                                -/  \+
  803.                                /    \
  804.                               /      *
  805.                              GK
  806.                            -/  \+
  807.                            /    \
  808.                           *      *
  809.    Now, we would like some way to eliminate the segments JC and CL, so
  810.        that we will be left with the boundary segments of the union.
  811.        Examine the segment BC in the tree. What we would like to do is
  812.        split BC with the hyperplane JF. Conveniently, we can do this by
  813.        _pushing_ the BC segment through the node for JF. The resulting
  814.        segments can be classified with the rest of the JF subtree. Notice
  815.        that the segment BJ lands in an out node, and that JC lands in an
  816.        in node. Remembering that we can discard interior nodes, we can
  817.        eliminate JC. The segment BJ replaces BC in the original tree.
  818.        This process is repeated for segment CD, yielding the segments CL
  819.        and LD. CL is discarded as landing in an interior node, and LD
  820.        replaces CD in the original tree. The result looks like this:
  821. 
  822. A               B
  823.  +-------------+
  824.  |             |
  825.  |             |
  826.  |             |J       F
  827.  |             +-------+
  828.  |                     |
  829.  |                     |
  830.  |        L            |
  831.  +-------+             |
  832. D        |             |
  833.          |             |
  834.          |             |
  835.          +-----+-------+
  836.         H      K        G
  837.  
  838.                         AB
  839.                       -/  \+
  840.                       /    \
  841.                      /      *
  842.                     BJ
  843.                   -/  \+
  844.                   /    \
  845.                  /      \
  846.                 LD       \
  847.               -/  \+      \
  848.               /    \       \
  849.              /      \       \
  850.             DA       \       \
  851.           -/  \+      \       \
  852.           /    \       \       \
  853.          *      *       \       \
  854.                         KH       \
  855.                       -/  \+      \
  856.                       /    \       \
  857.                      /      *       \
  858.                     HL              JF
  859.                   -/  \+          -/  \+
  860.                   /    \          /    \
  861.                  *      *        FG     *
  862.                                -/  \+
  863.                                /    \
  864.                               /      *
  865.                              GK
  866.                            -/  \+
  867.                            /    \
  868.                           *      *
  869.    As you can see, the result is the union of the polygons ABCD and EFGH.
  870.        
  871.        To perform other boolean operations, the process is similar. For
  872.        intersection, you discard segments which land in exterior nodes
  873.        instead of internal ones. The difference operation is special. It
  874.        requires that you invert the polytope before insertion. For simple
  875.        objects, this can be achieved by scaling with a factor of -1. The
  876.        insertion process is then cinducted as an intersection operation,
  877.        where segments landing in external nodes are discarded.
  878.        
  879.        _Tree merging_
  880.        
  881.        --
  882.        _Last Update: 11/27/95 16:26:21_
  883.        
  884.        _
  885.    How do you perform collision detection with a BSP Tree?_
  886.        
  887.        _Overview_
  888.        Detecting whether or not a point moving along a line intersects
  889.        some object in space is essentially a ray tracing problem.
  890.        Detecting whether or not two complex objects intersect is
  891.        something of a tree merging problem.
  892.        
  893.        Typically, motion is computed in a series of _Euler_ steps. This
  894.        just means that the motion is computed at discrete time intervals
  895.        using some description of the speed of motion. For any given point
  896.        P moving from point A with a velocity V, it's location can be
  897.        computed at time T as P = A + (T * V).
  898.        
  899.        Consider the case where T = 1, and we are computing the motion in
  900.        one second steps. To find out if the point P has collided with any
  901.        part of the scene, we will first compute the endpoints of the
  902.        motion for this time step. P1 = A + V, and P2 = A + (2 * V). These
  903.        two endpoints will be classified with respect to the BSP tree. If
  904.        P1 is outside of all objects, and P2 is inside some object, then
  905.        an intersection has clearly occurred. However, if P2 is also
  906.        outside, we still have to check for a collision in between.
  907.        
  908.        Two approaches are possible. The first is commonly used in
  909.        applications like games, where speed is critical, and accuracy is
  910.        not. This approach is to recursively divide the motion segment in
  911.        half, and check the midpoint for containment by some object.
  912.        Typically, it is good enough to say that an intersection occurred,
  913.        and not be very accurate about where it occurred.
  914.        
  915.        The second approach, which is more accurate, but also more time
  916.        consuming, is to treat the motion segment as a ray, and intersect
  917.        the ray with the BSP Tree. This also has the advantage that the
  918.        motion resulting from the impact can be computed more accurately.
  919.        --
  920.        _Last Update: 11/27/95 16:26:21_
  921.        
  922.        _
  923.    How do you handle dynamic scenes with a BSP Tree?_
  924.        
  925.        _Overview_
  926.        So far the discussion of BSP tree structures has been limited to
  927.        handling objects that don't move. However, because the hidden
  928.        surface removal algorithm is so simple and efficient, it would be
  929.        nice if it could be used with dynamic scenes too. Faster animation
  930.        is the goal for many applications, most especially games.
  931.        
  932.        The BSP tree hidden surface removal algorithm can easily be
  933.        extended to allow for dynamic objects. For each frame, start with
  934.        a BSP tree containing all the static objects in the scene, and
  935.        reinsert the dynamic objects. While this is straightforward to
  936.        implement, it can involve substantial computation.
  937.        
  938.        If a dynamic object is separated from each static object by a
  939.        plane, the dynamic object can be represented as a single point
  940.        regardless of its complexity. This can dramatically reduce the
  941.        computation per frame because only one node per dynamic object is
  942.        inserted into the BSP tree. Compare that to one node for every
  943.        polygon in the object, and the reason for the savings is obvious.
  944.        During tree traversal, each point is expanded into the original
  945.        object.
  946.        
  947.        _Implementation notes_
  948.        Inserting a point into the BSP tree is very cheap, because there
  949.        is only one front/back test at each node. Points are never split,
  950.        which explains the requirement of separation by a plane. The
  951.        dynamic object will always be drawn completely in front of the
  952.        static objects behind it.
  953.        
  954.        A dynamic object inserted into the tree as a point can become a
  955.        child of either a static or dynamic node. If the parent is a
  956.        static node, perform a front/back test and insert the new node
  957.        appropriately. If it is a dynamic node, a different front/back
  958.        test is necessary, because a point doesn't partition three
  959.        dimesnional space. The correct front/back test is to simply
  960.        compare distances to the eye. Once computed, this distance can be
  961.        cached at the node until the frame is drawn.
  962.        
  963.        An alternative when inserting a dynamic node is to construct a
  964.        plane whose normal is the vector from the point to the eye. This
  965.        plane is used in front/back tests just like the partition plane in
  966.        a static node. The plane should be computed lazily and it is not
  967.        necessary to normalize the vector.
  968.        
  969.        Cleanup at the end of each frame is easy. A static node can never
  970.        be a child of a dynamic node, since all dynamic nodes are inserted
  971.        after the static tree is completed. This implies that all subtrees
  972.        of dynamic nodes can be removed at the same time as the dynamic
  973.        parent node.
  974.        
  975.        _Advanced methods_
  976.        Tree merging, "ghosts", real dynamic trees... MORE TO COME
  977.        --
  978.        _Last Update: 11/27/95 16:26:21_
  979.        
  980.        _
  981.    How do you compute shadows with a BSP Tree?_
  982.        
  983.        _Overview_
  984.        
  985.        --
  986.        _Last Update: 11/27/95 16:26:21_
  987.        
  988.        _
  989.    How do you extract connectivity information from BSP Trees?_
  990.        
  991.        _Overview_
  992.        
  993.        --
  994.        _Last Update: 11/27/95 16:26:21_
  995.        
  996.        _
  997.    How are BSP Trees useful for robot motion planning?_
  998.        
  999.        _Overview_
  1000.        
  1001.        --
  1002.        _Last Update: 11/27/95 16:26:21_
  1003.        
  1004.        _
  1005.    How are BSP Trees used in DOOM?_
  1006.        
  1007.        _Overview_
  1008.        Before you can understand how DOOM uses a BSP tree to accelerate
  1009.        its rendering process, you have to understand how the world is
  1010.        represented in DOOM. When someone creates a DOOM level in a level
  1011.        editor they draw linedefs in a 2d space. Yes, that's right, DOOM
  1012.        is only 2d. These linedefs (ignoring the special effects linedefs)
  1013.        must be arranged so that they form closed polygons. One linedef
  1014.        may be used to form the outline of two polygons (in which case it
  1015.        is known as a two-sided linedef) and one polygon may be contained
  1016.        within another, but no linedefs may cross. Each enclosed area of
  1017.        the world (i.e. polygon) is assigned a floor height, ceiling
  1018.        height, floor and ceiling textures, a lower texture and an upper
  1019.        texture. The lower texture is visible when a linedef is viewed
  1020.        from a direction where the floor is lower in the adjoining area.
  1021.        An equivalent thing is true for the upper texture. A set of these
  1022.        enclosed areas that all have the same attributes is known as a
  1023.        sector.
  1024.        
  1025.        When the level is saved by the editor some new information is
  1026.        created including the BSP tree for that level. Before the BSP tree
  1027.        can be created, all the sectors have to be split into convex
  1028.        polygons known as sub-sectors. If you had a sector that was a
  1029.        square area, then that would translate exactly into a sub-sector.
  1030.        Whereas if that sector was contained inside another larger square
  1031.        sector, the larger one would have to be split into four, four
  1032.        sided sub-sectors to make all the sub-sectors convex. When more
  1033.        complex sectors are split into sub-sectors the linedefs that bound
  1034.        that sector may need to be broken into smaller lengths. These
  1035.        linedef sections are called segs.
  1036.        
  1037.        Given a point on the 2d map, the renderer (which isn't discussed
  1038.        here) wants a list of all the segs that are visible from that
  1039.        viewpoint in closest first order. Because of the restrictions
  1040.        placed on the DOOM world, the renderer can easily tell when the
  1041.        screen has been filled so it can stop looking for segs at this
  1042.        time. This is quicker than rendering all the segs from back to
  1043.        front and using a method like painters algorithm.
  1044.        
  1045.        Each node in the BSP tree defines a partition line (this does not
  1046.        have be a linedef in the world but usually is) which is the
  1047.        equivalent to the partition plane of a 3d BSP tree. It then has
  1048.        left and right pointers which are either another node for further
  1049.        sub-division or a leaf, the leaf being a sub-sector in DOOM. The
  1050.        BSP tree in DOOM is effectively being used to sort whole
  1051.        sub-sectors rather than individual lines front to back. Each node
  1052.        also defines an orthogonal bounding box for each side of the
  1053.        partition. All segs on a particular side of the partition must be
  1054.        within that box. This speeds up the searching process by allowing
  1055.        whole branches of the tree to be discarded if that bounding box
  1056.        isn't visible. The test for visibility is simply if the bounding
  1057.        box lies wholly or partly within the cone defined by the left and
  1058.        right edges of the screen.
  1059.        
  1060.        During the display update process the BSP tree is searched
  1061.        starting from the node containing the sub-sector that the player
  1062.        is currently in. The search moves outwards through the tree
  1063.        (searching the other half of the current node before moving onto
  1064.        the other half of the parents node). When a partition test is
  1065.        performed the branch chosen is the one on the same side as the
  1066.        player. This facilitates the front to back searching. Each time a
  1067.        leaf is encountered the segs in that sub-sector are passed to the
  1068.        renderer. If the renderer has returned that the screen is filled
  1069.        then the process stops, otherwise it continues until the tree has
  1070.        been fully searched (in which case there is an error in the level
  1071.        design).
  1072.        
  1073.        In case you're thinking that it is inefficient to dump a whole
  1074.        sub-sectors worth of segs into the renderer at once, the segs in a
  1075.        sub-sector can be back-face culled very quickly. DOOM stores the
  1076.        angle of linedefs (of which segs are part). When the angle of the
  1077.        players view is calculated this allows segs to be culled in a
  1078.        single instruction! Angles are stored as a 16 bit number where 0
  1079.        is east an 65535 is 1/63336 south of east.
  1080.        --
  1081.        _Last Update: 11/27/95 16:26:21_
  1082.        
  1083.        _
  1084.    How can you make a BSP Tree more robust?_
  1085.        
  1086.        _Overview_
  1087.        
  1088.        --
  1089.        _Last Update: 11/27/95 16:26:21_
  1090.        
  1091.        _
  1092.    How efficient is a BSP Tree?_
  1093.        
  1094.        _Space complexity_
  1095.        For hidden surface removal and ray tracing accelleration, the
  1096.        upper bound is O(n ^ 2) for n polygons. The expected case is O(n)
  1097.        for most models. MORE LATER
  1098.        
  1099.        _Time complexity_
  1100.        For hidden surface removal and ray tracing accelleration, the
  1101.        upper bound is O(n ^ 2) for n polygons. The expected case is O(n)
  1102.        for most models. MORE LATER
  1103.        --
  1104.        _Last Update: 11/27/95 16:26:21_
  1105.        
  1106.        _
  1107.    How can you make a BSP Tree more efficient?_
  1108.        
  1109.        _Bounding volumes_
  1110.        Bounding spheres are simple to implement, take only a single plane
  1111.        comparison, using the center of the sphere.
  1112.        
  1113.        _Optimal trees_
  1114.        Construction of an optimal tree is an NP-complete problem. The
  1115.        problem is one of splitting versus tree balancing. These are
  1116.        mutually exclusive requirements. You should choose your strategy
  1117.        for building a good tree based on how you intend to use the tree.
  1118.        
  1119.        _Minimizing splitting_
  1120.        An obvious problem with BSP trees is that polygons get split
  1121.        during the construction phase, which results in a larger number of
  1122.        polygons. Larger numbers of polygons translate into larger storage
  1123.        requirements and longer tree traversal times. This is undesirable
  1124.        in all applications of BSP trees, so some scheme for minimizing
  1125.        splitting will improve tree performance.
  1126.        
  1127.        Bear in mind that minimization of splitting requires pre-existing
  1128.        knowledge about all of the polygons that will be inserted into the
  1129.        tree. This knowledge may not exist for interactive uses such as
  1130.        solid modelling.
  1131.        
  1132.        _Tree balancing_
  1133.        Tree balancing is important for uses which perform spatial
  1134.        classification of points, lines, and surfaces. This includes ray
  1135.        tracing and solid modelling. Tree balancing is important for these
  1136.        applications because the time complexity for classification is
  1137.        based on the depth of the tree. Unbalanced trees have deeper
  1138.        subtrees, and therefore have a worse worst case.
  1139.        
  1140.        For the hidden surface problem, balancing doesn't significantly
  1141.        affect runtime. This is because the expected time complexity for
  1142.        tree traversal is linear on the number of polygons in the tree,
  1143.        rather than the depth of the tree.
  1144.        
  1145.        _Balancing vs. splitting_
  1146.        If balancing is an important concern for your application, it will
  1147.        be necessary to trade off some balance for reduced splitting. If
  1148.        you are choosing your hyperplanes from the polygon candidates,
  1149.        then one way to optimize these two factors is to randomly select a
  1150.        small number of candidates. These new candidates are tested
  1151.        against the full list for splitting and balancing efficiency. A
  1152.        linear combination of the two efficiencies is used to rank the
  1153.        candidates, and the best one is chosen.
  1154.        
  1155.        _Reference Counting_
  1156.        _Other Optimizations_
  1157.        
  1158.        --
  1159.        _Last Update: 11/27/95 16:26:21_
  1160.        
  1161.        _
  1162.    How can you avoid recursion?_
  1163.        
  1164.        standard binary tree search/sort techniques apply.
  1165.        --
  1166.        _Last Update: 11/27/95 16:26:21_
  1167.        
  1168.        _
  1169.    What is the history of BSP Trees?_
  1170.        
  1171.        _Overview_
  1172.        Neophyte: How did the BSP-Tree come to be?
  1173.        
  1174.        Sage: Long ago in a small village in Nepal, a minor godling gave a
  1175.        special nut to the priests at an out of the way temple. With the
  1176.        nut, was a prophecy: When a group of three gurus, two with red
  1177.        hair, and the other who was not what he seemed, came to the temple
  1178.        on pilgrimage, if the nut was given unto them, and they nurtured
  1179.        it together, it would produce a tree of great benefit to mankind.
  1180.        Many years later, ...
  1181.        
  1182.        N: no! No! NO! The TRUE story.
  1183.        
  1184.        S: OK.
  1185.        
  1186.        Long ago (by computer industry standards) in a rapidly growing
  1187.        sunbelt city in Texas, a serendipitous convergence of unusual
  1188.        talents and personalities occurred. A brief burst of graphics
  1189.        wonderments appeared, and the convergence diverged under its own
  1190.        explosive production, leading to further graphics developments in
  1191.        several new locations. One of the wonderous paths followed ...
  1192.        
  1193.        N: ...No! The facts!
  1194.        
  1195.        S: Huh? Oh you want FACTS. Boring stuff?
  1196.        
  1197.        Henry Fuchs started teaching at an essentially brand new campus,
  1198.        the University of Texas at Dallas, in January 1975. He returned to
  1199.        Utah to complete his PhD the following summer. He returned to
  1200.        Dallas and taught for the 1975-76, 1976-77 and 1977-78 academic
  1201.        years, before being lured away to UNC-Chapel Hill.
  1202.        
  1203.        Zvi Kedem joined this faculty in the fall of 1975. He was (and
  1204.        still is I suppose) a "theory person," but a special theory
  1205.        person. He is good at applying theory to practical problems.
  1206.        
  1207.        Bruce Naylor had a bachelors degree from the U of Texas (Austin -
  1208.        "the real one"), in philosophy if I recall correctly. He had
  1209.        talked his way into a job at Texas Instruments in Dallas.
  1210.        (Something about philosophy makes you good in logic, which is
  1211.        really the same as computers...!?) He came to UTD to take some
  1212.        computer courses. He was spotted as "good" - probably by Kedem,
  1213.        but I can't swear to it - and convinced to become a full time
  1214.        graduate student.
  1215.        
  1216.        Graphics, of course, is dazzling and wonderful. Henry was (is)
  1217.        full of energy and enthusiasm. It was natural that he attracted
  1218.        lots of the grad students. Kedem was a perfect complement,
  1219.        providing not only the formal rigor and proofs, but also the
  1220.        impetus to "write this part up" before going on to "the next thing
  1221.        and the next thing and ..." Kedem and Fuchs together (and most of
  1222.        the grad students) also found a new thrust in the CS theory
  1223.        community, called computational geometry, particularly
  1224.        interesting. Henry liked to talk about the Schumacker priority
  1225.        driven visible surface algorithm when the class got to that topic.
  1226.        He seemed to think there was something more to be done in that
  1227.        vein. Naylor being a grad student in search of a topic, looked
  1228.        into it.
  1229.        
  1230.        The result was two SIGGRAPH papers and Naylor's PhD dissertation,
  1231.        and the launch of BSP-trees into the world. The two papers are
  1232.        
  1233.        Fuchs, Kedem and Naylor, "Predeterming Visibility Priority in 3-D
  1234.        Scenes" SIGGRAPH '79, pp 175-181. (subtitled "preliminary report")
  1235.        
  1236.        
  1237.        and
  1238.        
  1239.        Fuchs, Kedem and Naylor, "On Visible Surface Generation by A
  1240.        Priori Tree Structures" SIGGRAPH '80, pp124-133.
  1241.        
  1242.        The first paper isn't really BSP-trees, but rather the preliminary
  1243.        work which led to BSP-trees as the solution. The second paper is
  1244.        the "classic" starting point referenced in texts, etc.
  1245.        
  1246.        Both reference Schumacker, Brand, Gilliland and Sharp, "Study for
  1247.        Applying Computer-Generated Images to Visual Simulation"
  1248.        AFHRL-TR-69-14, US AF Human Resources Lab, 1969
  1249.        
  1250.        and the description of this algorithm more easily found in
  1251.        
  1252.        Sutherland, Sproull and Schumacker, "A Characterization of Ten
  1253.        Hidden Surface Algorithms", ACM Computing Surveys, v 6, no 1, pp
  1254.        1-55.
  1255.        
  1256.        Naylor finished in 1981 (?) and went to Georgia Tech, and later to
  1257.        Bell Labs. He has continued to work on related and similar ideas
  1258.        with a variety of students and collaborators. Others have also
  1259.        taken the ideas in new directions.
  1260.        --
  1261.        _Last Update: 11/27/95 16:26:21_
  1262.        
  1263.        _
  1264.    Where can you find sample code and related online resources?_
  1265.        
  1266.        _BSP tree FAQ companion code_
  1267.        The companion source code to this document is available via FTP
  1268.        at:
  1269.        
  1270.           + file://ftp.qualia.com/pub/bspfaq/
  1271.             
  1272.    or, you can also request that the source be mailed to you by sending
  1273.        e-mail to bspfaq@qualia.com with a subject line of "SEND BSP TREE
  1274.        SOURCE". This will return to you a UU encoded copy of the sample
  1275.        C++ source code.
  1276.        
  1277.        _Other BSP tree resources_
  1278.        Pat Fleckenstein and Rob Reay have put together a FAQ on 3D
  1279.        graphics, which includes a blurb on BSP Trees, and an ftp site
  1280.        with some sample code. They seem to have an unusual affinity for
  1281.        ftp sites, and therefore won't link the BSP tree FAQ from their
  1282.        document:
  1283.        
  1284.           + http://www.csh.rit.edu/~pat/misc/3dFaq.html
  1285.           + file://ftp.csh.rit.edu/pub/3dfaq/
  1286.    
  1287.        
  1288.        Dr. Dobbs Journal has an article in their July '95 issue about BSP
  1289.        trees, By Nathan Dwyer. It describes the construction of BSP trees
  1290.        for visible surface processing, how to split polygons with planes,
  1291.        and how to dump the tree to a file. There is C++ source code to
  1292.        accompany the article.
  1293.        
  1294.           + http://www.ddj.com/ddj/issues/j9507a.htm
  1295.           + http://www.ddj.com/ddj/issues/j9507b.htm
  1296.    
  1297.        
  1298.        Michael Abrash's columns in the '95 DDJ Sourcebooks are an
  1299.        excellent introduction to the concept of BSP trees, especially in
  1300.        two dimensions. The source code for these is available as part of
  1301.        a package.
  1302.        
  1303.           + ftp://ftp.mv.com/pub/ddj/1995/1995.cpp/asc.zip
  1304.    
  1305.        
  1306.        Ekkehard Beier has made available a generic 3D graphics kernel
  1307.        intended to assist development of graphics application interfaces.
  1308.        One of the classes in the library is a BSP tree, and full source
  1309.        is provided. The focus seems to be on ray tracing, with the code
  1310.        being based on Jim Arvo's Linear Time Voxel Walking article in the
  1311.        ray tracing news.
  1312.        
  1313.           +
  1314.             ftp://metallica.prakinf.tu-ilmenau.de/pub/PROJECTS/GENERIC/gen
  1315.             eric1.1.tar.gz
  1316.    
  1317.        
  1318.        Eddie Edwards wrote a commonly referenced text which describes 2D
  1319.        BSP trees in some detail for use in games like DOOM. It includes a
  1320.        bit of sample code, too.
  1321.        
  1322.           +
  1323.             file://x2ftp.oulu.fi/pub/msdos/programming/theory/bsp_tree.zip
  1324.    
  1325.        
  1326.        Mel Slater has made available his C source code for computing
  1327.        shadow volumes based on BSP trees:
  1328.        
  1329.           + http://www.dcs.qmw.ac.uk/~mel/BSP.html
  1330.    
  1331.        
  1332.        _Graphics Gems_
  1333.        The Graphics Gems archive at
  1334.        file://ftp.princeton.edu/pub/Graphics/GraphicsGems/ is an
  1335.        invaluable resource for all things graphical. In particular, there
  1336.        are some BSP tree references worth looking over.
  1337.        
  1338.        Peter Shirley and Kelvin Sung have C sample code for ray tracing
  1339.        with BSP trees in Graphics Gems III
  1340.        
  1341.        Norman Chin has provided a wonderful resource for BSP trees in
  1342.        Graphics Gems V. He provides C sample code for a wide variety of
  1343.        uses.
  1344.        
  1345.        _More sources for sample BSP tree code_
  1346.           +
  1347.             file://ftp.idsoftware.com/tonsmore/utils/level_edit/node_build
  1348.             ers/
  1349.           + file://ftp.cs.brown.edu/pub/sphigs.tar.Z
  1350.    
  1351.        
  1352.        _General resources for computer graphics programming_
  1353.        Algorithm, Incorporated, an Atlanta-based Scientific and
  1354.        Engineering Research and Development Company specializing in
  1355.        Computer Graphics Programming and Business Internet
  1356.        Communications, has lots of good pointers and useful offerings.
  1357.        
  1358.        If you are interested in game programming, check out the
  1359.        rec.games.programmer.faq:
  1360.        http://www.ee.ucl.ac.uk/~phart/FAQ/rgp_FAQ.html.
  1361.        --
  1362.        _Last Update: 11/27/95 16:26:21_
  1363.        
  1364.        _
  1365.    References_
  1366.        
  1367.        A partial listing of textual info on BSP trees.
  1368.        
  1369.     1. _Abrash, M._, BSP Trees, _Dr. Dobbs Sourcebook_, _20_(14), 49-52,
  1370.        may/jun 1995.
  1371.        
  1372.     2. _Dadoun, N._, _Kirkpatrick, D._, and _Walsh, J._, The Geometry of
  1373.        Beam Tracing, _Proceedings of the ACM Symposium on Computational
  1374.        Geometry_, 55--61, jun 1985.
  1375.        
  1376.     3. _Chin, N._, and _Feiner, S._, Near Real-Time Shadow Generation
  1377.        Using BSP Trees, _Computer Graphics (SIGGRAPH '89 Proceedings)_,
  1378.        _23_(3), 99--106, jul 1989.
  1379.        
  1380.     4. _Chin, N._, and _Feiner, S._, Fast object-precision shadow
  1381.        generation for area light sources using BSP trees, _Computer
  1382.        Graphics (1992 Symposium on Interactive 3D Graphics)_, _25_(2),
  1383.        21--30, mar 1992.
  1384.        
  1385.     5. _Chrysanthou, Y._, and _Slater, M._, Computing dynamic changes to
  1386.        BSP trees, _Computer Graphics Forum (EUROGRAPHICS '92
  1387.        Proceedings)_, _11_(3), 321--332, sep 1992.
  1388.        
  1389.     6. _Naylor, B._, _Amanatides, J._, and _Thibault, W._, Merging BSP
  1390.        Trees Yields Polyhedral Set Operations, _Computer Graphics
  1391.        (SIGGRAPH '90 Proceedings)_, _24_(4), 115--124, aug 1990.
  1392.        
  1393.     7. _Chin, N._, and _Feiner, S._, Fast object-precision shadow
  1394.        generation for areal light sources using BSP trees, _Computer
  1395.        Graphics (1992 Symposium on Interactive 3D Graphics)_, _25_(2),
  1396.        21--30, mar 1992.
  1397.        
  1398.     8. _Naylor, B._, Interactive solid geometry via partitioning trees,
  1399.        _Proceedings of Graphics Interface '92_, 11--18, may 1992.
  1400.        
  1401.     9. _Naylor, B._, Partitioning tree image representation and
  1402.        generation from 3D geometric models, _Proceedings of Graphics
  1403.        Interface '92_, 201--212, may 1992.
  1404.        
  1405.    10. _Naylor, B._, {SCULPT} An Interactive Solid Modeling Tool,
  1406.        _Proceedings of Graphics Interface '90_, 138--148, may 1990.
  1407.        
  1408.    11. _Gordon, D._, and _Chen, S._, Front-to-back display of BSP trees,
  1409.        _IEEE Computer Graphics and Applications_, _11_(5), 79--85, sep
  1410.        1991.
  1411.        
  1412.    12. _Ihm, I._, and _Naylor, B._, Piecewise linear approximations of
  1413.        digitized space curves with applications, _Scientific
  1414.        Visualization of Physical Phenomena (Proceedings of CG
  1415.        International '91)_, 545--569, 1991.
  1416.        
  1417.    13. _Vanecek, G._, Brep-index: a multidimensional space partitioning
  1418.        tree, _Internat. J. Comput. Geom. Appl._, _1_(3), 243--261, 1991.
  1419.        
  1420.    14. _Arvo, J._, Linear Time Voxel Walking for Octrees, _Ray Tracing
  1421.        News_, feb 1988.
  1422.        
  1423.    15. _Jansen, F._, Data Structures for Ray Tracing, _Data Structures
  1424.        for Raster Graphics_, 57--73, 1986.
  1425.        
  1426.    16. _MacDonald, J._, and _Booth, K._, Heuristics for Ray Tracing Using
  1427.        Space Subdivision, _Proceedings of Graphics Interface '89_,
  1428.        152--63, jun 1989.
  1429.        
  1430.    17. _Naylor, B._, and _Thibault, W._, Application of BSP Trees to Ray
  1431.        Tracing and CSG Evaluation, _Tech. Rep. GIT-ICS 86/03_, feb 1986.
  1432.        
  1433.    18. _Sung, K._, and _Shirley, P._, Ray Tracing with the BSP Tree,
  1434.        _Graphics Gems III_, 271--274, 1992.
  1435.        
  1436.    19. _Fuchs, H._, _Kedem, Z._, and _Naylor, B._, On Visible Surface
  1437.        Generation by A Priori Tree Structures, _Conf. Proc. of SIGGRAPH
  1438.        '80_, _14_(3), 124--133, jul 1980.
  1439.        
  1440.    20. _Paterson, M._, and _Yao, F._, Efficient Binary Space Partitions
  1441.        for Hidden-Surface Removal and Solid Modeling, _Discrete and
  1442.        Computational Geometry_, _5_(5), 485--503, 1990.
  1443.        
  1444.        
  1445.        --
  1446.        _Last Update: 11/27/95 16:26:21_
  1447.        
  1448.    
  1449.      _________________________________________________________________
  1450.    
  1451.    BSP Tree FAQ (bspfaq@qualia.com)
  1452.